package com.mmall.common;

import com.google.common.collect.Sets;

import java.util.Set;

/**
 * Created by 陈吉鑫
 * 下面封装了 静态属性 接口 枚举
 */
public class Const {

    public static final String CURRENT_USER = "currentUser";

    public static final String EMAIL = "email";
    public static final String USERNAME = "username";
    public interface ProductListOrderBy{
        Set<String> PRIC_ASC_DESC=Sets.newHashSet("price_asc","price_desc");
    }
    public interface Role{
        int ROLE_CUSTOMER = 0; //普通用户
        int ROLE_ADMIN = 1;//管理员
    }
    public interface Cart{
        int CHECKED=1;//购物车为选中状态
        int UN_CHECKED=0;//购物车为未选中状态
        String LIMIT_NUM_FAIL="LIMIT_NUM_FAIL";//限制成功
        String LIMIT_NUM_SUCCESS="LIMIT_NUM_SUCCESS";//限制失败
    }
    public enum ProductsStatusEnum{
        ON_SALE(1,"在线");
        private int code;
        private String value;
        ProductsStatusEnum(int code,String value){
            this.code=code;
            this.value=value;
        }
        public int getCode() {
            return code;
        }
        public String getValue() {
            return value;
        }
    }


    public enum OrderStatusEnum{
        CANCELED(0,"已取消"),
        NO_PAY(10,"未支付"),
        PAID(20,"已支付"),
        SHIPPED(40,"已发货"),
        ORDER_SUCCESS(50,"订单完成"),
        ORDER_CLOSE(60,"订单关闭");
        OrderStatusEnum(int code,String value){
            this.value=value;
            this.code=code;
        }
        private String value;
        private int code;
        public String getValue() {
            return value;
        }
        public int getCode() {
            return code;
        }
        //通过传入的code的值 得到相应的枚举
        public static OrderStatusEnum codeOf(int code){
            for(OrderStatusEnum orderStatusEnum:values()){
                if(orderStatusEnum.getCode()==code){
                    return orderStatusEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }

    }

    public interface ApilayCallback{
        //等待买家付款
        String TRADE_STATUS_WAIT_BUYER_PAY="WAIT_BUYER_PAY";
        //交易完成
        String TRADE_STATUS_TRADE_SUCCESS="TRADE_SUCCESS";
        //交易成功
        String RESPONSE_SUCCESS="success";
        //交易失败
        String RESPONSE_FAILED="failed";
    }


    // 支付平台是什么
    public enum PayPlatFormEnum{
        ALIPAY(1,"支付宝");
        PayPlatFormEnum(int code,String value){
            this.value=value;
            this.code=code;
        }
        private String value;
        private int code;
        public String getValue() {
            return value;
        }
        public int getCode() {
            return code;
        }
    }

    public enum paymentTypeEnum{
        ONLINE_PAY(1,"在线支付");
        paymentTypeEnum(int code,String value){
            this.value=value;
            this.code=code;
        }
        private String value;
        private int code;
        public String getValue() {
            return value;
        }
        public int getCode() {
            return code;
        }
        //通过传入的code的值 得到相应的枚举
        public static paymentTypeEnum codeOf(int code){
            for(paymentTypeEnum paymentTypeEnum:values()){
                if(paymentTypeEnum.getCode()==code){
                    return paymentTypeEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举");
        }


    }


}





